<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Question_sale extends CI_Controller {
    function __controller() {
        parent::Controller();
    }

    /**
     * шаблон для поиск , не задействованный
     */
    public function index() {
        return;
    }

    ######################################  поиск объявлений  ########################################

    /**
     * форма для поиска по аренде домов
     *//**
     * форма для поиска по аренде квартир
     */
    public function flat($idr = false) {
        $data['maps'] = '';
        $data['region']['title'] = '';

        $output['region'] = 7700000000000;

        if ($idr == false) {
            parse_str($_SERVER['QUERY_STRING'], $output);
        } else {
            $output['region'] = $idr;
        }

        #	print_r($output);

        $data['region']['default'] = $output['region'];

        $this -> load -> model('Views_modul', 'views');

        $this -> load -> model('Adsent_modul', 'adsent');

        $output = $this -> adsent -> rq($output);

        $data['region']['ar'] = $titles = $this -> adsent -> region();

        if ($output['region'] == '7700000000000') {
            $metros['m'] = $metros['l'] = $this -> adsent -> metrosearch(1);

            $data['maps'] = $this -> load -> view('question/metro/msk', $metros, true);
        }

        if ($output['region'] == '7800000000000') {
            $metros['m'] = $this -> adsent -> metrosearch(2);
            $data['maps'] = $this -> load -> view('question/metro/spb', $metros, true);

        }

        foreach ($titles as $key => $value) {
            if ($value['code'] == $output['region']) {
                $data['region']['title'] = $rg = $value['fullname'];
            }
        }

        if (!isset($rg)) {
            $rg = "В Москве";
        }
        $this -> views -> title = 'Поиск объявления по продаже квартир и комнат ' . $rg;

        $this -> views -> content = $this -> load -> view('question/sale/flat', $data, true);

        $this -> views -> menu = 'search';
        $this -> views -> left = '';
        $this -> views -> pathway = '';

        $this -> views -> head = '';

        $content = $this -> views -> request_view();
        $this -> load -> view('home', $content);
    }

    /**
     * форма для поиска по аренде домов
     */

    public function suburbian($idr = false) {
        $data['maps'] = '';
        $data['region']['title'] = '';
        $output['region'] = 7700000000000;

        if ($idr == false) {
            parse_str($_SERVER['QUERY_STRING'], $output);
        } else {
            $output['region'] = $idr;
        }
        #	print_r($output);

        $data['region']['default'] = $output['region'];

        $this -> load -> model('Views_modul', 'views');

        $this -> load -> model('Adsent_modul', 'adsent');

        $output = $this -> adsent -> rq($output);

        $data['region']['ar'] = $titles = $this -> adsent -> region();

        if ($output['region'] == '7700000000000') {
            $metros['m'] = $metros['l'] = $this -> adsent -> metrosearch(1);

            $data['maps'] = $this -> load -> view('question/metro/msk', $metros, true);
        }

        if ($output['region'] == '7800000000000') {
            $metros['m'] = $this -> adsent -> metrosearch(2);
            $data['maps'] = $this -> load -> view('question/metro/spb', $metros, true);

        }

        foreach ($titles as $key => $value) {
            if ($value['code'] == $output['region']) {

                $data['region']['title'] = $rg = $value['fullname'];

            }
        }

        if (!isset($rg)) {
            $rg = "В Москве";
        }
        $this -> views -> title = 'Поиск объявления по продаже домов и земельных участоков ' . $rg;

        $this -> views -> content = $this -> load -> view('question/sale/suburbian', $data, true);

        $this -> views -> menu = 'search';
        $this -> views -> left = '';
        $this -> views -> pathway = '';

        $this -> views -> head = '';

        $content = $this -> views -> request_view();
        $this -> load -> view('home', $content);
    }

    /**
     * форма для поиска по аренде офисов
     */

    public function office($idr = false) {
        $data['maps'] = '';
        $data['region']['title'] = '';

        $output['region'] = 7700000000000;

        if ($idr == false) {
            parse_str($_SERVER['QUERY_STRING'], $output);
        } else {
            $output['region'] = $idr;
        }
        #	print_r($output);

        $data['region']['default'] = $output['region'];

        $this -> load -> model('Views_modul', 'views');

        $this -> load -> model('Adsent_modul', 'adsent');

        $output = $this -> adsent -> rq($output);

        $data['region']['ar'] = $titles = $this -> adsent -> region();

        if ($output['region'] == '7700000000000') {
            $metros['m'] = $metros['l'] = $this -> adsent -> metrosearch(1);

            $data['maps'] = $this -> load -> view('question/metro/msk', $metros, true);
        }

        if ($output['region'] == '7800000000000') {
            $metros['m'] = $this -> adsent -> metrosearch(2);
            $data['maps'] = $this -> load -> view('question/metro/spb', $metros, true);

        }

        foreach ($titles as $key => $value) {
            if ($value['code'] == $output['region']) {
                $data['region']['title'] = $rg = $value['fullname'];
            }
        }

        if (!isset($rg)) {
            $rg = "В Москве";
        }
        $this -> views -> title = 'Поиск объявления по продаже коммерческой недвижимости ' . $rg;

        $this -> views -> content = $this -> load -> view('question/sale/office', $data, true);

        $this -> views -> menu = 'search';
        $this -> views -> left = '';
        $this -> views -> pathway = '';

        $this -> views -> head = '';

        $content = $this -> views -> request_view();
        $this -> load -> view('home', $content);
    }

}
